﻿using System;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.Utilities;
using System.Web;

namespace SharePointExtendedDetailsFeature.Layouts.SharePointExtendedDetailsFeature
{
    public partial class NewItem : LayoutsPageBase
    {
        private string _newPageUrl;
        private string _title;
        private string _objectGuid;

        protected void Page_Load(object sender, EventArgs e)
        {
            // Populate field values from querystring
            _newPageUrl = Page.Request.QueryString["NewFormUrl"];
            _title = Page.Request.QueryString["Title"];
            _objectGuid = Page.Request.QueryString["ObjectGuid"];

            // Set a disable action on the Yes button
            btnYes.Attributes.Add("onclick", "javascript:" + btnYes.ClientID + ".disabled=true;" + ClientScript.GetPostBackEventReference(btnYes, ""));

        }

        protected void btnYes_Click(object sender, EventArgs e)
        {
            // Redirect to the default new item form for the list and add querystring values
            SPUtility.Redirect(_newPageUrl, SPRedirectFlags.Default, HttpContext.Current, "IsDlg=1&ObjectGuid=" + _objectGuid + "&Title=" + _title);
        }
    }
}
